<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<script>
	function goInsert() {
		var form = document.getElementById("flowerForm");
		form.action = '/admin/koreaflower/flower/insert.html';
		form.submit();
	}
	function goUpdate() {
		var form = document.getElementById("flowerForm");
		form.action = '/admin/koreaflower/flower/update.html';
		form.submit();
	}
</script>
<form id="flowerForm" name="flowerForm" method="post">
<c:if test="${not empty flower}">
<input type="hidden" name="id" value="${flower.id}"/>
<input type="hidden" name="categoryId" value="${flower.categoryId}"/>
</c:if>
<table>
	<tr>
		<td>
			<table>
				<tr>
					<th>name</th>
					<td><input type="text" name="name" value="${flower.name}"/></td>
				</tr>	
				<tr>
					<th>imagePath1</th>
					<td><input type="text" name="imagePath1" value="${flower.imagePath1}"/></td>
				</tr>	
				<tr>
					<th>imagePath2</th>
					<td><input type="text" name="imagePath2" value="${flower.imagePath2}"/></td>
				</tr>	
				<tr>
					<th>imagePath3</th>
					<td><input type="text" name="imagePath3" value="${flower.imagePath3}"/></td>
				</tr>	
				<tr>
					<th>imagePath4</th>
					<td><input type="text" name="imagePath4" value="${flower.imagePath4}"/></td>
				</tr>	
				<tr>
					<th>imagePaht5</th>
					<td><input type="text" name="imagePaht5" value="${flower.imagePaht5}"/></td>
				</tr>	
				<tr>
					<th>salePrice</th>
					<td><input type="text" name="salePrice" value="${flower.salePrice}"/></td>
				</tr>	
				<tr>
					<th>originalPrice</th>
					<td><input type="text" name="originalPrice" value="${flower.originalPrice}"/></td>
				</tr>	
				<tr>
					<th>comment</th>
					<td><input type="text" name="comment" value="${flower.comment}"/></td>
				</tr>	
				<tr>
					<th>eventYN</th>
					<td><input type="text" name="eventYN" value="${flower.eventYN}"/></td>
				</tr>	
				<tr>
					<th>seasonOnlyYN</th>
					<td><input type="text" name="seasonOnlyYN" value="${flower.seasonOnlyYN}"/></td>
				</tr>	
				<tr>
					<th>saleYN</th>
					<td><input type="text" name="saleYN" value="${flower.saleYN}"/></td>
				</tr>	
				<tr>
					<th>newYN</th>
					<td><input type="text" name="newYN" value="${flower.newYN}"/></td>
				</tr>	
				<tr>
					<th>soldOutYN</th>
					<td><input type="text" name="soldOutYN" value="${flower.soldOutYN}"/></td>
				</tr>	
				<tr>
					<th>useYN</th>
					<td><input type="text" name="useYN" value="${flower.useYN}"/></td>
				</tr>	
			</table>
		</td>
		<td width="30"></td>
		<td valign="top">
			<p>태그목록</p>
			<table>
				<c:forEach items="${tags}" var="each">
				<tr>
					<td>${each.id}</td>
					<td>${each.name}</td>
					<td>${each.eventYN}</td>
				</tr>
				</c:forEach>
			</table>
			<table>
				<c:forEach items="${flowerTagRefs}" var="each">
				<tr>
					<th>태그</th>
					<td><input type="text" id="tagIds" name="tagIds" value="${each.tagId}"></td>
				</tr>
				</c:forEach>
			</table>
		</td>
	</tr>
</table>

<div>
	<c:if test="${empty flower}"><input type="button" value="저장" onclick="goInsert()"/></c:if>
	<c:if test="${not empty flower}"><input type="button" value="수정" onclick="goUpdate()"/></c:if>
</div>
</form>
